
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fm" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link href="${pageContext.request.contextPath}/statics/assets/css/bootstrap.min.css" rel="stylesheet" />
    <link rel="stylesheet" href="${pageContext.request.contextPath}/statics/css/style.css"/>
    <link href="${pageContext.request.contextPath}/statics/assets/css/codemirror.css" rel="stylesheet">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/statics/assets/css/ace.min.css" />
    <link rel="stylesheet" href="${pageContext.request.contextPath}/statics/font/css/font-awesome.min.css" />
    <!--[if lte IE 8]>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/statics/assets/css/ace-ie.min.css" />
    <![endif]-->
    <script src="${pageContext.request.contextPath}/statics/js/jquery-1.9.1.min.js"></script>
    <script src="${pageContext.request.contextPath}/statics/assets/js/bootstrap.min.js"></script>
    <script src="${pageContext.request.contextPath}/statics/assets/js/typeahead-bs2.min.js"></script>
    <script src="${pageContext.request.contextPath}/statics/assets/js/jquery.dataTables.min.js"></script>
    <script src="${pageContext.request.contextPath}/statics/assets/js/jquery.dataTables.bootstrap.js"></script>
    <script src="${pageContext.request.contextPath}/statics/assets/layer/layer.js" type="text/javascript" ></script>
    <script src="${pageContext.request.contextPath}/statics/assets/laydate/laydate.js" type="text/javascript"></script>
    <script src="${pageContext.request.contextPath}/statics/js/lrtk.js" type="text/javascript" ></script>
    <title>订单处理</title>

</head>

<body>
<div class="clearfix">
    <div class="order_list_style" id="order_list_style" style="margin-left: 20px;">
        <div class="search_style" style="margin: 10px 0px;">
            <form action="${pageContext.request.contextPath}/manager/order/list?orderType=${orderType}&&pageindex=1" method="get" class="form-inline">
                <input type="hidden" name="pageindex" value="1"/>
                <div class="form-group">
                    <label>订单号:</label>
                    <input type="text" name="outTradeNo" value="${outTradeNo}">
                </div>
                <div class="form-group">
                    <button type="submit" class="btn btn-info">查询</button>
                </div>
            </form>
        </div>
        <!--交易订单列表-->
        <div class="Orderform_list">
            <table class="table table-striped table-bordered table-hover" id="sample-table">
                <thead>
                <tr>
                    <th width="25px"><label><input type="checkbox" class="ace"><span class="lbl"></span></label></th>
                    <th width="120px">订单编号</th>
                    <th width="100px">订单金额</th>
                    <th width="100px">交易时间</th>
                    <th width="180px">优惠卷</th>
                    <th width="80px">实付金额</th>
                    <th width="100px">优惠金额</th>
                    <th width="70px">状态</th>
                    <th width="200px">操作</th>
                </tr>
                </thead>
                <tbody>
                <c:forEach var="o" items="${pageInfo.list}">
                    <tr>
                        <td><label><input type="checkbox" class="ace"><span class="lbl"></span></label></td>
                        <td>${o.outTradeNo}</td>
                        <td class="order_product_name">
                                ${o.totalAmount}
                        </td>
                        <td><fmt:formatDate value="${o.placeOrderTime}" pattern="yyyy-MM-dd"/> </td>

                        <td> ${o.useCoupon}</td>
                        <td>${o.payPrice}</td>
                        <td>${o.couponPrice}</td>
                        <td class="td-status"><span class="label label-success radius">
                        <c:choose>
                            <c:when test="${o.orderType==1}">
                                未支付
                            </c:when>
                            <c:when test="${o.orderType==2}">
                                已支付
                            </c:when>
                            <c:when test="${o.orderType==3}">
                                已发货
                            </c:when>
                            <c:when test="${o.orderType==4}">
                                骑手接单
                            </c:when>
                            <c:when test="${o.orderType==5}">
                                已完成
                            </c:when>
                            <c:when test="${o.orderType==6}">
                                取消订单
                            </c:when>
                            <c:when test="${o.orderType==6}">
                                已删除订单
                            </c:when>
                        </c:choose>
                    </span></td>
                        <td>
                            <a title="删除订单" href="javascript:;"  onclick="Order_form_del(this, '${o.outTradeNo}')" class="btn btn-xs btn-warning" ><i class="fa fa-trash  bigger-120"></i></a>
                        </td>
                    </tr>
                </c:forEach>
                </tbody>
            </table>
            </div>
        <div class="container text-center">
            <nav aria-label="Page navigation">
                <ul class="pagination">
                    <li>
                        <c:choose>
                            <c:when test="${pageInfo.isFirstPage}">
                                <a href="${pageContext.request.contextPath}/manager/order/list?orderType=${orderType}&pageindex=1" aria-label="Previous">
                                    <span aria-hidden="true">&laquo;</span>
                                </a>
                            </c:when>
                            <c:otherwise>
                                <a href="${pageContext.request.contextPath}/manager/order/list?orderType=${orderType}&pageindex=${pageInfo.prePage}" aria-label="Previous">
                                    <span aria-hidden="true">&laquo;</span>
                                </a>
                            </c:otherwise>
                        </c:choose>
                    </li>
                    <%--el标签的其中一个for循环--%>
                    <c:choose>
                        <c:when test="${pageInfo.pages<=10}">
                            <c:set var="startpage" value="1"></c:set>
                            <c:set var="endpage" value="${pageInfo.pages}"></c:set>
                        </c:when>
                        <c:otherwise>
                            <c:choose>
                                <c:when test="${pageInfo.pageNum<5}">
                                    <c:set var="startpage" value="1"></c:set>
                                    <c:set var="endpage" value="10"></c:set>
                                </c:when>
                                <c:when test="${pageInfo.pages-pageInfo.pageNum<=5}">
                                    <c:set var="startpage" value="${pageInfo.pageNum-10}"></c:set>
                                    <c:set var="endpage" value="${pageInfo.pageNum}"></c:set>
                                </c:when>
                                <c:otherwise>
                                    <c:set var="startpage" value="${pageInfo.pageNum-4}"></c:set>
                                    <c:set var="endpage" value="${pageInfo.pageNum+5}"></c:set>
                                </c:otherwise>
                            </c:choose>
                        </c:otherwise>
                    </c:choose>
                    <c:forEach begin="${startpage}" end="${endpage}" step="1" varStatus="status">
                        <c:choose>
                            <c:when test="${status.index==pageInfo.pageNum}">
                                <li class="active">
                            </c:when>
                            <c:otherwise>
                                <li>
                            </c:otherwise>
                        </c:choose>
                        <a href="${pageContext.request.contextPath}/manager/order/list?orderType=${orderType}&pageindex=${status.index}">${status.index}</a></li>
                    </c:forEach>
                    <li>
                        <c:choose>
                            <c:when test="${pageInfo.isLastPage}">
                                <a href="${pageContext.request.contextPath}/manager/order/list?orderType=${orderType}&pageindex=${pageInfo.pages}" aria-label="Next">
                                    <span aria-hidden="true">&raquo;</span>
                                </a>
                            </c:when>
                            <c:otherwise>
                                <a href="${pageContext.request.contextPath}/manager/order/list?orderType=${orderType}&pageindex=${pageInfo.nextPage}" aria-label="Next">
                                    <span aria-hidden="true">&raquo;</span>
                                </a>
                            </c:otherwise>
                        </c:choose>
                    </li>
                </ul>
            </nav>
        </div>
    </div>
</div>

</body>
</html>

<script>
    function Order_form_del(target,id) {
        var isok = confirm("确认要删除吗？");
        console.log(id);

        if (isok){
            $.getJSON("${pageContext.request.contextPath}/manager/order/del",{"id":id},function (e) {
                if (e.code==200){
                    alert(e.message);
                    /*删除dom元素*/
                    $(target).parent().parent().remove();
                    window.location.href="${pageContext.request.contextPath}/manager/order/list?pageindex=1"
                }else {
                    alert(e.message)
                    // console.log(e)
                }
            })
        }
    }

</script>